<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class System_mdl extends MY_Model {

    public function __construct(){
        parent::__construct();
        $this->table = 'system';
    }


    /**
     * 获取系统信息
     */
    public function get_sys(){
        if(!empty($_SESSION['sys'])){
            return true;
        }

        //获取系统信息
        $sys = $this->cache->get('ci_sys');
        if(empty($sys)){
            $this->db->where('id',1);
            $sys = $this->get_one();
            $this->cache->save('ci_sys', $sys);
        }
        $this->session->set_userdata(['sys' => $sys]);

        return true;
    }

    /**
     * 更新
     */
    public function update($data = array()){
        $this->cache->delete('ci_sys');
        if(empty($data)){
            $res = $this->db->update($this->table);
        }else{
            $res = $this->db->update($this->table,$data);
        }
        return $res;
    }

}

/* End of file System_mdl.php */
/* Location: ./application/models/System_mdl.php */